<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Exception;

class AdCompanies extends Model
{
    protected $table = "ad_companies";
    public $timestamps = false;

    const STATUS_ON =1;
    const STATUS_OFF = 2;

    static $StatusDisplay = [
        self::STATUS_ON=>'未删除',
        self::STATUS_OFF=>'已删除',
    ];


    /**
     * 添加公司
     * @param $name
     * @param $remarkes
     * @return array
     */
    static function CompanyPublish($name, $remarkes)
    {
        $company = new AdCompanies();
        $company->name = $name;
        $company->remarks = $remarkes;
        $company->created_at = time();

        try {
            if (!$company->save()) {
                return error('添加失败');
            }
        } catch (Exception $exception) {
            logger($exception->getMessage());
            return error('添加失败');
        }

        return success();
    }
}
